package org.diysearch.dao.interfaces;

import java.sql.SQLException;
import java.util.List;

import org.diysearch.dao.filters.LinkFilter;
import org.diysearch.models.Link;

public interface LinkDao {
	
	public int save(Link link) throws SQLException;
	public int save(List<Link> links) throws SQLException;
	public int move(LinkFilter filter) throws SQLException;
	
	/**
	 * get links for a given category, and you may specify an optional filter
	 * which is just a dynamic chunk of sql
	 * @param categoryId
	 * @param filter
	 * @return
	 * @throws SQLException
	 */
	public List<Link> findByCategory(LinkFilter filter) throws SQLException;
	public List<Link> findByOwner (LinkFilter filter) throws SQLException;
	public List<Link> findByTag (LinkFilter filter) throws SQLException;
	public List<Link> findByRating (LinkFilter filter) throws SQLException;
	public List<Link> findByEditorPick (LinkFilter filter) throws SQLException;
	
	/**
	 * status is basically for links approved or unapproved
	 * @param status
	 * @return
	 * @throws SQLException
	 */
	public List<Link> findByStatus (int status) throws SQLException;
	
	/**
	 * basically a generic method to fetch links for a given chunk of
	 * sql (as defined by the filter)
	 * @param filter
	 * @return
	 * @throws SQLException
	 */
	public List<Link> findByFilter(LinkFilter filter) throws SQLException;
	public Link findById(int id, int status) throws SQLException;
	public int delete (Link link) throws SQLException;
	public int delete (List<Link> links) throws SQLException;
	
	public int incrementClickthru (Link link) throws SQLException;
	public int incrementImpression (Link link) throws SQLException;
	public int setAsEditorPick (Link link) throws SQLException;
	public int setAsActive (Link link) throws SQLException;
	public int incrementRating (Link link) throws SQLException;
	public int deincrementRating (Link link) throws SQLException;
	
}
